<?php

namespace app\modules\setting\models\null;

use sookie\db\ITRecordModel;
use yii\data\ArrayDataProvider;

/**
 * 记录 "set_null_rwsz" 的模型类.
 *
 * @property string $day_times 每日发送频率.
 * @property string $job_num 每批的任务数.
 * @property string $creators_per_job 每个任务发送达人数.
 * @property string $last_creator_send_id 最后发送的创作者ID.
 * @property string $product_num 每个类型选取产品数量.
 * @property string $goods_per_store 单店铺最大选品数量（0=不限）.
 * @property string $min_sale 最低销量（0=不限）.
 * @property string $min_price 最低价格（0=不限）.
 * @property string $min_pf 最低评分（0=不限）.
 * @property string $min_yj 最低佣金比例（0=不限）.
 * @property string $is_bp 是否爆品（0=不限，-1=否，1是）.
 * @property string $is_new 是否新品（0=不限，-1=否，1是）.
 * @property string $is_brand 是否品牌（0=不限，-1=否，1是）.
 * @property string $zq_days 周期间隔.
 * @property string $drsj 导入时间，最近N天.
 */
class SetNullRwsz extends \sookie\db\RecordModel implements ITRecordModel
{
    /**
     * {@inheritdoc}
     */
    public static function getRecordID()
    {
        return 'set_null_rwsz';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [[["day_times","job_num","creators_per_job","last_creator_send_id","product_num","goods_per_store","min_sale","min_price","min_pf","min_yj","is_bp","is_new","is_brand","zq_days","drsj"],"safe"]];
    }

    /**
    * @param array $params
    * @return ArrayDataProvider
    * 搜索
    */
    public function search($params = []){

        $query = self::find();

        $this->load($params);

        $query->andFilterWhere(['like', 'day_times', $this->day_times]);
        $query->andFilterWhere(['like', 'job_num', $this->job_num]);
        $query->andFilterWhere(['like', 'creators_per_job', $this->creators_per_job]);
        $query->andFilterWhere(['like', 'last_creator_send_id', $this->last_creator_send_id]);
        $query->andFilterWhere(['like', 'product_num', $this->product_num]);
        $query->andFilterWhere(['like', 'goods_per_store', $this->goods_per_store]);
        $query->andFilterWhere(['like', 'min_sale', $this->min_sale]);
        $query->andFilterWhere(['like', 'min_price', $this->min_price]);
        $query->andFilterWhere(['like', 'min_pf', $this->min_pf]);
        $query->andFilterWhere(['like', 'min_yj', $this->min_yj]);
        $query->andFilterWhere(['like', 'is_bp', $this->is_bp]);
        $query->andFilterWhere(['like', 'is_new', $this->is_new]);
        $query->andFilterWhere(['like', 'is_brand', $this->is_brand]);
        $query->andFilterWhere(['like', 'zq_days', $this->zq_days]);
        $query->andFilterWhere(['like', 'drsj', $this->drsj]);
        
        return new ArrayDataProvider([
            'allModels' => $query->all(),
            'pagination' => [
                'pageSize' => 10,
            ],
            'sort' => [
                'attributes' => ["day_times","job_num","creators_per_job","last_creator_send_id","product_num","goods_per_store","min_sale","min_price","min_pf","min_yj","is_bp","is_new","is_brand","zq_days","drsj"],
            ],
        ]);
    }
}
